import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity('users')
export class wxUser {
  @PrimaryGeneratedColumn()
  id: number;

  @Column(['openid'])
  openid: string;

  @Column(['unionid'])
  unionid: string;

  @Column({default: '微信用户'})
  nickname: string;

  @Column({default: null})
  avatar_url: string;

  @Column({default: null})
  phone: number;
  
  @Column({default: 0})
  points: number;

  @Column({default: 1})
  memberLevel: number;

  @Column({default: 0})
  coins: number;
  
  @Column({default: null})
  last_login_time: Date;

  @Column({default: () => 'CURRENT_TIMESTAMP'})
  create_time: Date;

  @Column({default: () => 'CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'})
  update_time: Date;
}
@Entity('merchant_admins')
export class merchant_admins {
  @PrimaryGeneratedColumn()
  id: number;
  @Column({type:'json'})
  merchant_id: number; 
  @Column({default: () => null})
  username: string;
  @Column({default: () => null})
  password: string;
  @Column({default: () => null})
  real_name: string;
  @Column({default: () => null})
  phone: string;
  @Column({default: () => null})
  email: string;
  @Column({default: 0})
  role: number;
  @Column({default: 1})
  status: number;
  @Column({default: () => null})
  last_login_time:Date;
  @Column({default: () => 'CURRENT_TIMESTAMP'})
  create_time: Date;
  @Column({default: () => 'CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'})
  update_time: Date;
}
@Entity('merchants')
export class merchants {
  @PrimaryGeneratedColumn()
  id: number;
  @Column({default: null})
  name: string; 
  @Column({default: null})
  logo_url: string;
  @Column({default: null})
  cover_image: string;
  @Column({default: null})
  description: string;
  @Column({default: null})
  address: string;
  @Column({default: null})
  longitude: string;
  @Column({default: null})
  latitude: string;
  @Column({default: null})
  phone: string;
  @Column({default: null})
  business_hours: string;
  @Column({default: 5})
  rating: number;
  @Column({default: 0})
  monthly_sales: number;
  @Column({default: 0})
  average_price: number;
  @Column({default: 0})
  status: number;
  @Column({default: null})
  admin_id: number;
  @Column({default: () => 'CURRENT_TIMESTAMP'})
  create_time: Date;
  @Column({default: () => 'CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'})
  update_time: Date;
}
@Entity('user_address')
export class address {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  user_id: string;

  @Column()
  name: string;

  @Column()
  phone: string;
  
  @Column()
  area: string;

  @Column()
  detail: string;

  @Column({default: 0})
  isDefault: number;

  @Column({default: () => 'CURRENT_TIMESTAMP'})
  created_at: Date;

  @Column({default: () => 'CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'})
  updated_at: Date;
}